package Day2025_03_03;

import java.util.ArrayList;
import java.util.List;

public class HomeWork04 {
    List<List<String>> ret;
    List<String> path;
    boolean[] tmp;
    public List<List<String>> permute(String[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        tmp = new boolean[nums.length];
        dfs(nums);
        return ret;
    }
    public void dfs (String[] nums) {
        if (path.size() == nums.length) {
            ret.add(new ArrayList<>(path));
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if (!tmp[i]) {
                path.add(nums[i]);
                tmp[i] = true;
                dfs(nums);
                path.remove(path.size() - 1);
                tmp[i] = false;
            }
        }
    }

    public static void main(String[] args) {
        HomeWork04 homeWork04 = new HomeWork04();
        System.out.println(homeWork04.permute(new String[]{"小紅", "小黃", "小蘭"}));
    }
}
